package data.connector.rippling.tigger;

import data.connector.rippling.api.base.BaseGenericService;
import data.connector.rippling.api.*;
import lombok.RequiredArgsConstructor;
import lombok.extern.log4j.Log4j2;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

/**
 * @author Jay Yang
 */
@Log4j2
@Service
@RequiredArgsConstructor
public class AsyncScheduleEvent extends BaseGenericService {

    private final CompaniesService companiesService;
    private final EmployeesService employeesService;
    private final DepartmentsService departmentsService;
    private final CustomFieldsService customFieldsService;
    private final LevelsService levelsService;
    private final PaySchedulesService paySchedulesService;
    private final CompanyDeductionsService companyDeductionsService;
    private final EmployeeDeductionsService employeeDeductionsService;
    private final LeaveRequestsService leaveRequestsService;
    private final CompanyActivityService companyActivityService;


    @Scheduled(fixedDelay = 1000 * 60 * 5)
    public void syncRipplingData() {
        this.companiesService.asyncCompanies(1);
        this.employeesService.asyncEmployees(1);
        this.departmentsService.asyncDepartments(1);
        this.customFieldsService.asyncCustomFields(1);
        this.levelsService.asyncLevels(1);
        this.paySchedulesService.asyncPaySchedules(1);
        this.companyDeductionsService.asyncCompanyDeductions(1);
        this.employeeDeductionsService.asyncEmployeeDeductions(1);
        this.leaveRequestsService.asyncLeaveRequests(1);
        this.companyActivityService.asyncCompanyActivity(1);
    }

}
